package com.liezh.builder.builder;

import com.liezh.builder.builder.TextConverter;

/**
 * Director：代表需要建造最终对象的某种算法
 * 用于构造使用builder接口的实例对象
 */
public class RTFReader {

    private TextConverter mTextConverter;

    public RTFReader(TextConverter textConverter) {
        this.mTextConverter = textConverter;
    }

    public void parseRTF(String... type) {
        for (String t : type) {
            if (t == null || "".equals(t))
                throw new RuntimeException("转换格式不支持！");
            if ("char".equals(t.toLowerCase())) {
                mTextConverter.convertCharacter(t);
            } else if ("font".equals(t.toLowerCase())) {
                mTextConverter.convertFontChange(t);
            } else if ("para".equals(t.toLowerCase())) {
                mTextConverter.convertParagraph();
            } else {
                throw new RuntimeException("转换格式不支持！");
            }
        }

    }
}
